Object: Task
Symbol:
You configure the task in the object. You can configure the priority, the type with time behavior, and a watchdog. You can also add PROGRAM
calls.
The object is located in the device tree below the Task Configuration.
Tab: Configuration
Object: Task
Priority | Possible values: 0..31, where 0 is the highest priority |
Task group | Assigned task group which can be assigned to specific processor cores in multicore Example: IEC-Tasks Note: The task group is shown in brackets after the task in the device tree. |
Important
When using a runtime system in Linux, there exist fixed dependencies between task groups and priorities. For more information, see: Mapping of Task Priorities on a Linux System
Type
Type: | Processing of the task is done cyclically. |
Input field: Interval | Required Time span after which the task is restarted (task cycle time)
Note: Deviations of the task from this desired task cycle time are displayed at runtime as periodic jitter on the Tab: Monitoring tab. |
Time unit of the interval | If only a number and not a time definition is specified in the Interval input field, then the unit selected here determines the time dimensions. Example: ms Note: A task cycle time in µs is always displayed as a number. |
Type: | Processing of the task starts event-triggered on the rising edge of the event variable. |
Input field: Event | Global variable (Boolean type) The task starts as soon as the variable value switches from 0 to 1. |
Type: | Processing of the task starts event-triggered on the rising edge of the event variable. |
List box: Event | List with target system-dependent events (Boolean type) Note: The target system determines which events are supported and offered in the list box. Hint: Not to be confused with system events |
Interval | Time definition in Note: Only available when the event requires a time definition |
Type: | Processing of the task restarts automatically in a continuous loop at program start and after the end of a run after a certain waiting time Important: After completing a run, a certain amount of time is waited before the task is executed again. The duration is a percentage of the last cycle duration. Note: You do not define a cycle time. |
Type: | Processing of the task starts state-triggered by the event variables |
Input field: Event | Global variable (Boolean type) When the variable has the state Note: The variable is typically reset in the task itself. In contrast to the event task, no event can be missed in this way. When an event occurs, the scheduler must save an old value, and this can change more often than it is checked. So if an event variable changes to |
Important
For fieldbuses, a fixed cycle matrix is necessary to assure a determined behavior. Therefore, you should not use the Freewheeling type for a bus cycle task.
Important
Note the following difference between the processing types Status and Event: if the given event yields TRUE
, then the start condition of a task of type Status is fulfilled. In contrast, the start of a task of type Event requires a switch of the event from FALSE
to TRUE
. If the sampling rate of the task scheduler is too low, then the rising edge of the event can remain unnoticed.
Important
When setting the task cycle time, you need to identify which bus system is currently being used. For example, the task cycle time in a CAN bus system must match the currently set baud rate and the number of frames used in the bus. In addition, the times set for heartbeat, node guarding, and sync should always be a multiple of the task cycle time. If not, then CAN frames can be lost.
For more information, see: Tab: Monitoring
Watchdog
Defines the time monitoring for a task. If the target system supports an advanced watchdog configuration, then the following settings may be predefined in the device description.
The default watchdog settings depend on the device. | |
Enable |
If the task exceeds the currently set time of the watchdog, then the task is halted with an error status (exception). The application in whose task the error occurred and its child applications are also halted. In this way, all tasks of the affected applications are also halted. Then the currently defined Sensitivity is also taken into account. If you activate the option Update I/Os in the PLC Settings of the PLC, then CODESYS resets the outputs to the defined default values. . Possible cases:
|
Time (e.g. t#200ms) | Watchdog time Defines (together with Sensitivity) the watchdog for a task; description as for Enable. Depending on the target system, the monitoring time span is given as a percentage of the task interval if possible. In this case, the list box for the unit is disabled and displays %. |
Sensitivity | Number Defines (together with the watchdog) the watchdog for a task; description as for Enable. |
Tip
Using the functions from the library CmpIecTask.library
, you can deactivate a watchdog for specific PLC cycles. This is useful for cycles that demand more time due to initialization.
Deactivating/reactivating the watchdog:
VAR hIecTask : RTS_IEC_HANDLE; END_VAR hIecTask := IecTaskGetCurrent(0); IecTaskDisableWatchdog(hIecTask); //Watchdog disabled ... IecTaskEnableWatchdog(hIecTask); //Watchdog enabled
The watchdog is deactivated before initialization with IecTaskDisableWatchDog
for the rest of the cycle and is automatically reactivated at the next cycle.
The watchdog can be reactivated after initialization with IecTaskEnableWatchDog
. The watchdog is then already reactivated for the rest of the cycle (the watchdog time window starts again from the beginning).
Initializations of function blocks which happen within the FB_Init
method are not affected by this. But there was the limit of < 30 seconds because of the communication timeout. This time limit no longer exists since V3.5 SP18 because the online services are executed asynchronously.
Tip
The normal watchdog of an IEC task is triggered when the execution time of the IEC task exceeds the watchdog time.
The "Omitted Cycle" watchdog is triggered when the task does not start at all. This is the case when the task does not execute any cycle at all within the maximum of <Time * Sensitivity> or <2 * Interval>. The cause could be crowding by other tasks or a failure in the scheduler, which no longer enables the task.
Program calls
POUs (POU object with type The order in which the POUs are called corresponds to the call order configured here from top to bottom. | |
| Opens the Input Assistant. Select a |
| Removes the call |
| Opens the Input Assistant for the selected call. Select another |
| Moves the position of the call up or down in the list. The call order changes accordingly at runtime. |
| Opens the POU editor with the declaration and implementation of the |